package com.liang;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * Created with Intellij IDEA
 *
 * @Auther: liangjy
 * @Date: 2021/12/23/18:09
 * @Description:
 * @LoadBalanced:声明一个基于Ribbon的负载均衡。标注此注解后，RestTemplate就具有了客户端负载均衡的能力。
 */
@SpringBootApplication
public class RibbonApplication {
    public static void main(String[] args) {
        SpringApplication.run(RibbonApplication.class, args);
    }
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
